package project3;

import java.util.Scanner;

public class note {
    public static void toupiao(student[] std)
    {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入你的名字：");
        student sb=new student();
        int i=0,j,k=0,flag=1,c=0;
        sb.name=sc.next();
        while(std[i]!=null)
        {
            String a=String.valueOf(std[i].use);
            boolean x=a.equals(String.valueOf(1));
            if(x&&std[i].name.equals(sb.name))
            {
                System.out.println("不可以重复投票");
                flag=0;
                break;
            }
            boolean y=(std[i].name.equals(sb.name));
            if(y)
            {
                flag=0;
                std[i].use=1;
                c=1;
                break;
            }
            i++;
        }
        if(flag==1)
        {
            for(k=0;std[k]!=null;k++);
            std[k]=new student();
            std[k].name=sb.name;
            std[k].use=1;
            c=1;
        }
        String a=String.valueOf(std[i].use);
        boolean x=a.equals(String.valueOf(0));
        if(x||c==1) {
            System.out.println("请输入要投票的姓名：");
            i = 0;
            flag = 1;
            sb.name = sc.next();
            while (std[i] != null) {
                boolean y = (std[i].name.equals(sb.name));
                if (y) {
                    std[i].note = std[i].note + 1;
                    flag = 0;
                    break;
                }
                i++;
            }
            if (flag == 1) {
                for (k = 1; std[k] != null; k++) ;
                std[k] = new student();
                std[k].name = sb.name;
                std[k].note++;
            }
        }
    }
}
